package com.shop.admin.controller.Admin;

import com.shop.entity.dto.AdminWares.*;
import com.shop.entity.pojo.Wares;
import com.shop.admin.service.*;
import com.shop.utils.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wares")
@Slf4j
public class AdminWaresController {

    @Autowired
    private WaresService waresService;
    @Autowired
    private StyleService styleService;
    @Autowired
    private CostService costService;
    @PostMapping("save_wares")
    public Result saveWares(@RequestBody AdminWaresSaveDto dto){
        log.info("后台管理-添加商品");
        return waresService.saveWares(dto);
    }

    @PostMapping("remove_wares")
    public Result removeWares(@RequestBody AdminWaresRemoveDto dto){
        log.info("后台管理-删除商品");
        return waresService.removeWares(dto);
    }

    @PostMapping("update_get_wares")
    public Result<Wares> updateGetWares(@RequestBody AdminWaresUpdateForGetDto dto){
        log.info("后台管理-修改商品数据回显");
        return waresService.updateGetWares(dto);
    }

    @PostMapping("update_wares")
    public Result updateWares(@RequestBody AdminWaresUpdateDto dto){
        log.info("后台管理-修改商品");
        return waresService.updateWares(dto);
    }

    @PostMapping("open_wares")
    public Result openWares(@RequestBody AdminWaresOpenDto dto){
        log.info("后台管理-恢复商品");
        return waresService.openWares(dto);
    }

    @PostMapping("pull_wares")
    public Result pullWares(@RequestBody AdminWaresPullDto dto){
        log.info("后台管理-下架商品");
        return waresService.pullWares(dto);
    }

    @PostMapping("put_wares")
    public Result putWares(@RequestBody AdminWaresPutDto dto){
        log.info("后台管理-上架商品");
        return waresService.putWares(dto);
    }

    @PostMapping("get_wares_list")
    public Result<List<Wares>> getWaresList(@RequestBody AdminWaresListDto dto){
        log.info("后台管理-商品列表");
        return waresService.getWaresList(dto);
    }

    @PostMapping("get_wares_detail")
    public Result getWaresDetail(@RequestBody AdminWaresStyleListDto dto){
        log.info("后台管理-商品相关款式");
        return styleService.getWaresDetail(dto);
    }

    @PostMapping("get_wares_cost")
    public Result getWaresCost(@RequestBody AdminWaresCostListDto dto){
        log.info("后台管理-商品相关价格");
        return costService.getWaresCost(dto);
    }



}
